/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

#ifndef SAMPLE_SIMPLE_DESCRIBEREGIONSRESPONSE_H_
#define SAMPLE_SIMPLE_DESCRIBEREGIONSRESPONSE_H_

// includes
#include <string>
#include <vector>

#include "AcsResponse.h"

namespace aliyun {

namespace ecs {

namespace v20140526 {

class DescribeRegionsResponse : public AcsResponse {
 public:

  // subtype
  class Region {
   public:
    const std::string& getLocalName() const {
      return localName;
    }

    void setLocalName(const std::string& localName) {
      this->localName = localName;
    }

    const std::string& getRegionId() const {
      return regionId;
    }

    void setRegionId(const std::string& regionId) {
      this->regionId = regionId;
    }

   private:
    std::string regionId;

    std::string localName;
  };

  IMPLEMENT_CLASSNAME(DescribeRegionsResponse)

  static DescribeRegionsResponse unmarshall(UnmarshallerContext context) {
    using aliyun::utils::StringUtils::ToString;
    DescribeRegionsResponse response;
    response.setRequestId(
        context.stringValue("DescribeRegionsResponse.RequestId"));

    std::vector<Region> regions;
    int length = context.lengthValue("DescribeRegionsResponse.Regions.Length");
    for (int i = 0; i < length; i++) {
      Region region;

      region.setRegionId(context.stringValue("DescribeRegionsResponse.Regions[" + ToString(i) + "].RegionId"));
      region.setLocalName(context.stringValue("DescribeRegionsResponse.Regions[" + ToString(i) + "].LocalName"));

      regions.push_back(region);
    }
    response.setRegions(regions);
    return response;
  }

  // getters and setters
  const std::vector<Region>& getRegions() const {
    return regions;
  }

  void setRegions(const std::vector<Region>& regions) {
    this->regions = regions;
  }

  const std::string& getRequestId() const {
    return requestId;
  }

  void setRequestId(const std::string& requestId) {
    this->requestId = requestId;
  }

 private:
  // fields

  std::string requestId;

  std::vector<Region> regions;
};

}  // namespace v20140526

}  // namespace ecs

}  // namespace aliyun

#endif  // SAMPLE_SIMPLE_DESCRIBEREGIONSRESPONSE_H_
